<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    const worker = new Worker('worker.js')
    worker.postMessage({
      message: 'hello worker'
    })
    worker.onmessage = e => {
      console.log('主线程', e)
    }
  </script>
</body>

</html>